package com.practice.blog.common.utils;

import com.practice.blog.common.pojo.dataobject.BlogInfo;
import com.practice.blog.common.pojo.dataobject.UserInfo;
import com.practice.blog.common.pojo.request.AddBlogParam;
import com.practice.blog.common.pojo.request.UpdateBlogParam;
import com.practice.blog.common.pojo.response.BlogInfoResponse;
import com.practice.blog.common.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-30
 * Time: 14:43
 */
public class BeanConver {
    public static BlogInfoResponse trans(BlogInfo blogInfo) {
        BlogInfoResponse blogInfoResponse = new BlogInfoResponse();
        if(blogInfo != null) {
            BeanUtils.copyProperties(blogInfo,blogInfoResponse);
        }
        return blogInfoResponse;
    }

    public static UserInfoResponse trans(UserInfo userInfo) {
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        if(userInfo != null) {
            BeanUtils.copyProperties(userInfo,userInfoResponse);
        }
        return userInfoResponse;
    }


    public static BlogInfo trans(AddBlogParam addBlogParam) {
        //将addBlogParam转成 BlogInfo
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(addBlogParam,blogInfo);
        return blogInfo;
    }

    public static BlogInfo trans(UpdateBlogParam param) {
        //将addBlogParam转成 BlogInfo
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(param,blogInfo);
        return blogInfo;
    }


}
